<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>专项管理</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"></div>
                <div class="layui-card-body">
                    <!-- 添加专项案件 -->
                    <div class="panel panel-default operation_case" hidden>
                        <div class="panel-heading title"></div>
                        <div class="layui-card-body">
                            <form class="layui-form " action="" lay-filter="deptInfo"
                                  style="width: 700px;margin-top: 10px">
                                <input name="id" hidden/>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">案件名称</label>
                                    <div class="layui-input-block">
                                        <input name="name" placeholder="请输入案件名称" autocomplete="off"
                                               class="layui-input">
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">状态</label>
                                    <div class="layui-input-block">
                                        <input type="checkbox" name="status" lay-skin="switch" lay-filter="switch"
                                               lay-text="有效|无效"
                                               checked>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button type="submit" class="layui-btn" lay-submit="" lay-filter="submit">保存
                                        </button>
                                        <button class="layui-btn layui-btn-primary" id="btn_cancel">返回</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <!-- 专项案件列表 -->
                    <div class="case_table_div">
                        <table class="layui-hide" id="case_table" lay-filter="case_table"></table>
                    </div>
                    <!-- 专项案件明细 -->
                    <div class="case_ajxx_table_div" hidden>
                        <form id="searchParamAjxx" style="margin-left: 10px">
                            <label for="zxajId"></label>
                            <input id="zxajId" name="zxajId" hidden/>
                            <div class="layui-form-item">
                                <div class="layui-input-inline">
                                    <label for="s_nsrmc"></label>
                                    <input type="text" id="s_nsrmc" class="layui-input" autocomplete="off"
                                           placeholder="请输入企业名称">
                                </div>
                                <div class="layui-input-inline">
                                    <label for="s_nsrsbh"></label>
                                    <input type="text" id="s_nsrsbh" class="layui-input" autocomplete="off"
                                           placeholder="请输入纳税人识别号">
                                </div>
                                <div class="layui-input-inline">
                                    <label for="s_ajbh"></label>
                                    <input type="text" id="s_ajbh" class="layui-input" autocomplete="off"
                                           placeholder="请输入案件编号">
                                </div>
                                <div class="layui-input-inline" style="width: auto">
                                    <button type="button" class="layui-btn" onclick="searchAjxx()" id="search">查询
                                    </button>
                                    <button type="button" class="layui-btn" onclick="reset()">重置</button>
                                    <button type="button" class="layui-btn" onclick="pldel()" id="pldel">批量删除
                                    </button>
                                    <button class="layui-btn layui-btn-primary" id="btn_cancel_imp">返回</button>
                                </div>
                            </div>
                        </form>
                        <table class="layui-hide" id="case_ajxx_table" lay-filter="case_ajxx_table"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="addNewCase">添加</button>
    </div>
</script>

<script type="text/html" id="zxajmxToolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="inputZxaj">导入专项案件</button>
        <button class="layui-btn layui-btn-sm" lay-event="downloadMx">专项案件明细模板下载</button>
        <button class="layui-btn layui-btn-sm" lay-event="inputZxajmx">导入专项案件明细</button>
    </div>
</script>
<!--专项案件-->
<script type="text/html" id="tool">
    {{#  if(d.swjgDm == '12101009100'){  }}
    {{#  if(d.name == '团伙虚开案件' || d.name == '举报案件' || d.name == '审理重点案件' || d.name == '积案' ){ }}
    <a class="layui-btn layui-btn-xs" lay-event="ajxx">案件</a>
    {{#  }else { }}
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    <a class="layui-btn layui-btn-xs" lay-event="ajxx">案件</a>
    {{#  } }}
    {{# }else { }}
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    <a class="layui-btn layui-btn-xs" lay-event="ajxx">案件</a>
    {{#  } }}
</script>
<!--专项案件明细-->
<script type="text/html" id="ajxxtool">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="ajxxdel">删除</a>
</script>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script th:inline="none">
    //获取token
    var token = CoreUtil.getData("access_token");
    //地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    var tableIns1;
    var tableAjxx;
    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var upload = layui.upload;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var tree = layui.tree;
    var startTime = null;
    var endTime = null;
    layui.config({
        base: '/'
    }).extend({
        eleTree: 'layui-ext/eleTree/eleTree'
    }).use(['table', 'laypage', 'layer', 'laydate', 'tree', 'eleTree', 'upload'], function () {
        const eleTree = layui.eleTree;
        // 专项案件表
        tableIns1 = table.render({
            elem: '#case_table'
            , contentType: 'application/json'
            , headers: {"authorization": token}
            , page: true //开启分页
            , url: '/attention/specialCaseManagement/list' //数据接口
            , method: 'POST'
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null : res.data.records //解析数据列表
                }
            }
            , cols: [
                [
                    {
                        field: 'name', title: '案件名称', width: 400, align: 'center'
                    },
                    {
                        field: 'status', title: '状态', width: 100, align: 'center', templet: function (item) {
                            if (item.status === 1) {
                                return '  <input type="checkbox" lay-skin="switch" lay-text="有效|无效" checked disabled>';
                            }
                            if (item.status === 0) {
                                return '  <input type="checkbox" lay-skin="switch" lay-text="有效|无效" disabled>';
                            }
                        }
                    },
                    {title: '操作', width: 250, align: 'center', toolbar: '#tool'}
                ]
            ]
            , toolbar: '#toolbar'
        });
        //专项案件明细表
        tableAjxx = table.render({
            elem: '#case_ajxx_table'
            , contentType: 'application/json'
            , headers: {"authorization": token}
            , page: true //开启分页
            , url: '/attention/specialCaseManagement/listajxx' //数据接口
            , method: 'POST'
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null : res.data.records //解析数据列表
                }
            }
            , cols: [
                [
                    {type: 'checkbox', fixed: 'left'},
                    {
                        field: 'ajbh', title: '案件编号', width: 200, align: "center", sort: true
                    },
                    {field: 'nsrsbh', title: '纳税人识别号', width: 200, align: "center", sort: true},
                    {field: 'nsrmc', title: '纳税人名称', width: 300, align: "center", sort: true},
                    {field: 'xpnd', title: '下派年度', width: 140, align: "center", sort: true},
                    {field: 'dbcj', title: '督办层级', width: 140, align: "center", sort: true},
                    {field: 'ajssdl', title: '案件所属大类', width: 240, align: "center", sort: true},
                    {field: 'aymc', title: '案源名称', width: 180, align: "center", sort: true},
                    {
                        field: 'larq',
                        title: '立案日期',
                        width: 140,
                        align: "center",
                        sort: true,
                        templet: function (d) {
                            if (!d.larq) {
                                return '';
                            }
                            return layui.util.toDateString(d.larq, 'yyyy-MM-dd');
                        }
                    },
                    {field: 'lats', title: '立案天数', width: 140, align: "center", sort: true},
                    {
                        field: 'cbe',
                        title: '查补额',
                        width: 160,
                        align: "center",
                        sort: true,
                        templet: function (d) {
                            return d.cbe ? parseFloat(d.cbe).toFixed(2) : '0.00';
                        }
                    },
                    {
                        field: 'rke',
                        title: '入库额',
                        width: 160,
                        align: "center",
                        sort: true,
                        templet: function (d) {
                            return d.rke ? parseFloat(d.rke).toFixed(2) : '0.00';
                        }
                    },
                    {
                        field: 'createTime',
                        title: '案件导入日期',
                        width: 140,
                        align: "center",
                        sort: true,
                        templet: function (d) {
                            if (!d.createTime) {
                                return '';
                            }
                            return layui.util.toDateString(d.createTime, 'yyyy-MM-dd');
                        }
                    },
                    {title: '操作', width: 100, align: "center", sort: true, toolbar: '#ajxxtool'}
                ]
            ]
            , toolbar: '#zxajmxToolbar'
        });
        //
        table.on('tool(case_ajxx_table)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'ajxxdel':
                    tipDialogAjxxdel(data.id);
                    break;
            }
        });
        laydate.render({
            elem: '#createTime'
            , type: 'datetime'
            , range: '~'
            , done: function (value) {
                if (value !== null && value !== undefined && value !== "") {
                    startTime = value.split("~")[0];
                    endTime = value.split("~")[1];
                } else {
                    startTime = null;
                    endTime = null;
                }
            }
        });
        table.on('toolbar(case_table)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'addNewCase':
                    //隐藏表格
                    $(".case_table_div").hide();
                    //显示编辑窗口
                    $(".operation_case").show();
                    $(".title").html("新增专项案件");
                    $(".operation_case input[name=id]").val("");
                    $(".operation_case input[name=name]").val("");
                    $(".operation_case input[name=status]").attr('checked', 'checked');
                    $(".operation_case input[name=status]").attr('type', 'hidden').val(1);
                    var x = document.getElementsByClassName("layui-unselect layui-form-switch");
                    x[0].setAttribute("class", "layui-unselect layui-form-switch layui-form-onswitch");
                    var d = document.getElementsByTagName('em')[0];
                    d.firstChild.nodeValue = '有效';
                    form.render(); //更新全部
                    break;
            }
        });
        // 明细表操作
        table.on('toolbar(case_ajxx_table)', function (obj) {
            let body = $('body');
            switch (obj.event) {
                case 'inputZxaj':
                    const zxajInput = $('<input type="file" accept=".xls,.xlsx">').css('display', 'none');

                    zxajInput.on('change', function () {
                        const file = this.files[0];
                        if (!file) return;

                        const formData = new FormData();
                        formData.append("file", file)
                        formData.append("zxajId", $("#zxajId").val());
                        $.ajax({
                            url: '/attention/inputZxaj_mb',
                            type: 'POST',
                            data: formData,
                            headers: {"authorization": token},
                            processData: false,
                            contentType: false,
                            beforeSend: function () {
                                layer.load();
                            },
                            success: function (res) {
                                let data = res.data; // {validDataCount: x, errorDataCount: y}
                                let code = res.code;
                                if (code === 500) {
                                    // 显示错误提示（红色警告图标 + 自定义标题）
                                    layer.alert(res.msg || "操作失败，请重试！", {
                                        icon: 2, // 2 表示错误图标（红色）
                                        title: '错误', // 弹窗标题
                                        skin: 'layui-layer-red' // 可选，增强红色警示效果（需 Layui 支持）
                                    });
                                } else {
                                    // 根据是否有失败数据决定提示内容
                                    if (data.errorDataCount > 0) {
                                        // 有失败的：显示成功+失败
                                        layer.alert(`成功导入 ${data.validDataCount} 条，失败 ${data.errorDataCount} 条`, {
                                            icon: data.validDataCount > 0 ? 1 : 2, // 成功>0用成功图标，否则用错误图标
                                            end: function () {
                                                searchAjxx(); // 刷新数据
                                            }
                                        });
                                    } else {
                                        // 全部成功：只显示成功
                                        layer.alert(`成功导入 ${data.validDataCount} 条`, {
                                            icon: 1, // 成功图标
                                            end: function () {
                                                searchAjxx();
                                            }
                                        });
                                    }
                                }
                                layer.closeAll('loading'); // 关闭loading
                            },
                            error: function (res) {
                                layer.closeAll('loading');
                                layer.alert(res.msg);
                            }
                        });
                    });

                    // 添加并触发
                    body.append(zxajInput);
                    zxajInput.trigger('click');
                    break;
                case 'downloadMx':
                    fetch('/attention/downloadZxajmx_mb', {
                        method: 'POST',
                        headers: {"authorization": token}
                    })
                        .then(response => response.blob())
                        .then(data => {
                            const blob = new Blob([data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
                            const link = document.createElement('a');
                            link.href = URL.createObjectURL(blob);
                            link.download = "专项案件明细模板.xlsx"; // 可指定文件名
                            document.body.appendChild(link);
                            link.click();
                            document.body.removeChild(link);
                        })
                        .catch(error => {
                            console.error('请求失败:', error);
                            alert('文件下载失败，请稍后重试');
                        });
                    break
                case 'inputZxajmx':
                    const zxajmxInput = $('<input type="file" accept=".xls,.xlsx">').css('display', 'none');

                    zxajmxInput.on('change', function () {
                        const file = this.files[0];
                        if (!file) return;

                        const formData = new FormData();
                        formData.append("file", file);

                        $.ajax({
                            url: '/attention/inputZxajmx_mb',
                            type: 'POST',
                            data: formData,
                            headers: {"authorization": token},
                            processData: false,
                            contentType: false,
                            beforeSend: function () {
                                layer.load();
                            },
                            success: function (res) {
                                let data = res.data; // {validDataCount: x, errorDataCount: y}

                                // 根据是否有失败数据决定提示内容
                                if (data.errorDataCount > 0) {
                                    // 有失败的：显示成功+失败
                                    layer.alert(`成功导入 ${data.validDataCount} 条，失败 ${data.errorDataCount} 条`, {
                                        icon: data.validDataCount > 0 ? 1 : 2, // 成功>0用成功图标，否则用错误图标
                                        end: function () {
                                            searchAjxx(); // 刷新数据
                                        }
                                    });
                                } else {
                                    // 全部成功：只显示成功
                                    layer.alert(`成功导入 ${data.validDataCount} 条`, {
                                        icon: 1, // 成功图标
                                        end: function () {
                                            searchAjxx();
                                        }
                                    });
                                }
                                layer.closeAll('loading'); // 关闭loading
                            },
                            error: function (res) {
                                layer.closeAll('loading');
                                layer.alert(res.msg);
                            }
                        });
                    });

                    // 添加并触发
                    body.append(zxajmxInput);
                    zxajmxInput.trigger('click');
                    break;
            }
        });
        // 专项案件操作
        table.on('tool(case_table)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'del':
                    tipDialog(data.id);
                    break;
                case 'edit':
                    $(".case_table_div").hide();
                    //显示编辑窗口
                    $(".operation_case").show();
                    $(".title").html("编辑案件");
                    getCaseDetail(data.id);
                    break;
                case 'ajxx':
                    searchAjxx(data.id);
                    $(".case_table_div").hide();
                    //显示编辑窗口
                    $(".operation_case").hide();
                    $(".operation_case_dataScope").show();
                    $(".case_ajxx_table_div").show();
                    $("#zxajId").val(data.id);
                    $(".title").html("案件");
                    break;
            }
        });
        var getCaseDetail = function (id) {
            CoreUtil.sendGet("/attention/specialCaseManagement/detail/" + id, null, function (res) {
                $(".operation_case input[name=id]").val(res.data.id);
                $(".operation_case input[name=name]").val(res.data.name);
                if (res.data.status == 1) {
                    $(".operation_case input[name=status]").attr('checked', 'checked');
                    $(".operation_case input[name=status]").attr('type', 'hidden').val(1);
                    var x = document.getElementsByClassName("layui-unselect layui-form-switch");
                    x[0].setAttribute("class", "layui-unselect layui-form-switch layui-form-onswitch");
                    var d = document.getElementsByTagName('em')[0];
                    d.firstChild.nodeValue = '有效';
                } else {
                    $(".operation_case input[name=status]").attr('type', 'hidden').removeAttr("checked").val(0);
                    var x = document.getElementsByClassName("layui-unselect layui-form-switch");
                    x[0].setAttribute("class", "layui-unselect layui-form-switch");
                    var d = document.getElementsByTagName('em')[0];
                    d.firstChild.nodeValue = '失效';
                }
                $(".operation_case_dataScope input[name=roleId]").val(res.data.id);
                if (!CoreUtil.isEmpty(res.data.dataScope)) {
                    $("#dataScopeS").find('option[value="' + res.data.dataScope + '"]').prop('selected', true);
                    $("#dataScope").val(res.data.dataScope)
                    if (res.data.dataScope == "2") {
                        $("#choose-dept").show();
                    }
                } else {
                    $("#dataScopeS option:first").prop("selected", 'selected');
                }
                // loadPermissionTree(res.data.permissionRespNodes);
                // loadDeptTree(res.data.deptRespNodes);
                form.render(); //更新全部

            });
        }
        //上传案件信息
        upload.render({
            elem: '#uploadExcel'
            , url: '/attention/specialCaseManagement/importByajbh'
            , data: {
                zxajId: function () {
                    return $("#zxajId").val();
                }
            }
            , auto: true,
            accept: 'file'
            , acceptMime: 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
            , exts: 'xls|xlsx'
            , before: function () {
                layer.load(); //上传loading
            }
            , done: function (res) {
                layer.alert(res.data);
                searchAjxx($("#zxajId").val());
                layer.closeAll('loading'); //关闭loaWding
            }
            , error: function () {
                layer.alert("导入案件失败，请重试！");
                layer.closeAll('loading'); //关闭loading
            }
        });
        var importByajbh = function (id) {
            CoreUtil.sendGet("/attention/specialCaseManagement/detail/" + id, null, function (res) {
                $(".operation_case input[name=id]").val(res.data.id);
                $(".operation_case input[name=name]").val(res.data.name);
                if (res.data.status == 1) {
                    $(".operation_case input[name=status]").attr('checked', 'checked');
                    $(".operation_case input[name=status]").attr('type', 'hidden').val(1);
                    var x = document.getElementsByClassName("layui-unselect layui-form-switch");
                    x[0].setAttribute("class", "layui-unselect layui-form-switch layui-form-onswitch");
                    var d = document.getElementsByTagName('em')[0];
                    d.firstChild.nodeValue = '有效';
                } else {
                    $(".operation_case input[name=status]").attr('type', 'hidden').removeAttr("checked").val(0);
                    var x = document.getElementsByClassName("layui-unselect layui-form-switch");
                    x[0].setAttribute("class", "layui-unselect layui-form-switch");
                    var d = document.getElementsByTagName('em')[0];
                    d.firstChild.nodeValue = '失效';
                }
                $(".operation_case_dataScope input[name=roleId]").val(res.data.id);
                if (!CoreUtil.isEmpty(res.data.dataScope)) {
                    $("#dataScopeS").find('option[value="' + res.data.dataScope + '"]').prop('selected', true);
                    $("#dataScope").val(res.data.dataScope)
                    if (res.data.dataScope == "2") {
                        $("#choose-dept").show();
                    }
                } else {
                    $("#dataScopeS option:first").prop("selected", 'selected');
                }
                // loadPermissionTree(res.data.permissionRespNodes);
                // loadDeptTree(res.data.deptRespNodes);
                form.render(); //更新全部

            });
        }
        var isChooseFile = function (obj) {
            //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
            obj.preview(function (index, file, result) {
                console.log(index); //得到文件索引
                console.log(file); //得到文件对象
                console.log(result); //得到文件base64编码，比如图片
            });
            console.log(obj);
        };
        var doneFileUp = function (res, index, upload) {
            layer.alert('导入成功doneFileUp')
            layer.closeAll('loading'); //关闭loading
        };
        var beforeFileUp = function (obj) {
            layer.load(); //上传loading
        };
        var initTree = function () {
            CoreUtil.sendGet("/sys/permission/tree/all", null, function (res) {
                loadPermissionTree(res.data);
            });
        };
        var loadPermissionTree = function (data) {
            tree.render({
                elem: '#permissionTree'
                , data: data
                , onlyIconControl: true  //是否仅允许节点左侧图标控制展开收缩
                , showCheckbox: true  //是否显示复选框
                , id: 'permissionIds'
                , accordion: false
                , click: function (obj) {
                    selectNode = obj;
                    layer.msg(JSON.stringify(selectNode.data.title));
                }
            });
        };
        var el;
        var loadDeptTree = function (data) {
            $("#deptTree").html("");
            el = eleTree({
                el: '#deptTree',
                data: data,
                highlightCurrent: true,
                showCheckbox: true,
                isDefaultChangePstatus: true,
                checkStrictly: true,
                draggable: true,
                defaultExpandAll: true
            })
        };
        form.on('switch(switch)', function () {
            $(".operation_case input[name=status]").attr('type', 'hidden').val(this.checked ? 1 : 0);

        });
        $("#btn_cancel").click(function () {
            $(".case_table_div").show();
            $(".operation_case").hide();
            $(".operation_case_dataScope").hide();
            return false;
        });
        $("#btn_cancel_imp").click(function () {
            $(".case_table_div").show();
            $(".operation_case").hide();
            $(".operation_case_dataScope").hide();
            $(".case_ajxx_table_div").hide();
            return false;
        });
        //监听提交 新增案件
        form.on('submit(submit)', function (data) {
            console.log(data);
            var params = {
                id: data.field.id,
                name: data.field.name,
                status: data.field.status,
            }
            if (data.field.id === undefined || data.field.id === null || data.field.id === "") {
                CoreUtil.sendPost("/attention/specialCaseManagement/add", params, function (res) {
                    $(".case_table_div").show();
                    $(".operation_case").hide();
                    $(".operation_case_dataScope").hide();
                    search();
                });
            } else {
                CoreUtil.sendPost("/attention/specialCaseManagement/update", params, function (res) {
                    //显示表格
                    $(".case_table_div").show();
                    //隐藏编辑窗口
                    $(".operation_case").hide();
                    $(".operation_case_dataScope").hide();
                    search();
                });
            }
            return false;
        });
        $("#submit_importByAjbh").click(function () {
            var params = {
                zxajId: $("#zxajId").val()
            }
            CoreUtil.sendPost("/attention/specialCaseManagement/importByajbh", params, function (res) {
                layer.alert('导入成功#submit_importByAjbh')
            });
        });
        //监听提交
        form.on('submit(submit_importByAjbh)', function (data) {
            var params = {
                zxajId: $("#zxajId").val()
            }
            CoreUtil.sendPost("/attention/specialCaseManagement/importByajbh", params, function (res) {
                // //显示表格
                layer.alert('导入成功submit')
            });

            return false;
        });
        var tipDialog = function (id) {
            layer.open({
                content: '确定要删除么',
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendPost("/attention/specialCaseManagement/deleted/" + id, null, function (res) {
                        layer.msg(res.msg);
                        search();
                    });
                }
            });
        }
        var tipDialogAjxxdel = function (id) {
            layer.open({
                content: '确定要删除么',
                yes: function (index) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendPost("/attention/specialCaseManagement/deletedajxx/" + id, null, function (res) {
                        layer.msg(res.msg);
                        searchAjxx();
                    });
                }
            });
        }
    });

    //专项案件查询
    function search() {
        tableIns1.reload({
            where: { //设定异步数据接口的额外参数，任意设
                status: $("#status").val(),
                startTime: startTime,
                endTime: endTime,
            }
            , page: {
                curr: 1 //重新从第 1 页开始
            }
        });
    }

    //执行查询
    function pldel() {
        var caseId = $("#zxajId").val();
        var checkStatus = table.checkStatus('case_ajxx_table'),
            data = checkStatus.data,
            ajxxIds = "";
        if (data.length > 0) {
            for (var i in data) {
                ajxxIds += data[i].id + ",";
            }
            console.log(ajxxIds);//打印获取到选中的id，用，分割
            layer.open({
                content: '确定要删除选择的案件吗？',
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendPost("/attention/specialCaseManagement/pldeletedajxx/" + ajxxIds, null, function (res) {
                        layer.msg(res.msg);
                        searchAjxx(caseId);
                    });
                }
            });
        } else {
            layer.msg("请选择需要删除的案件");  //如果未选择数据，则提示。
        }
    }

    //专项案件明细查询
    function searchAjxx(caseId) {
        tableAjxx.reload({
            where: { //设定异步数据接口的额外参数，任意设
                caseId: caseId,
                nsrmc: $("#s_nsrmc").val(),
                nsrsbh: $("#s_nsrsbh").val(),
                ajbh: $("#s_ajbh").val(),
            }
            , page: {
                curr: 1 //重新从第 1 页开始
            }
        });
    }

    //重置
    function reset() {
        $('#s_nsrmc').val(''); // 清空输入框
        $('#s_nsrsbh').val(''); // 清空输入框
        $('#s_ajbh').val(''); // 清空输入框
    }
</script>
</body>

</html>